//
// Created by Administrator on 2024/3/17.
//
// O(nlog(n))排序+最长平台（简单dp）
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
const int maxn = 2000000 + 500;
int a[maxn], dp[maxn], n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        if (a[i] == a[i - 1])dp[i] = dp[i - 1] + 1;
        else dp[i] = 1;
    }
    int p = max_element(dp + 1, dp + n + 1) - dp;

    cout << a[p] << endl;
    cout << dp[p] << endl;


    return 0;
}